package com.yogee.topseller.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.SparseBooleanArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.yogee.core.utils.ToastUtils;
import com.yogee.topseller.R;
import com.yogee.topseller.activity.login.model.bean.InterestLabelBean;
import com.yogee.topseller.bean.ProductInfoBean;
import com.yogee.topseller.utils.AppUtil;
import com.yogee.topseller.utils.pinyinUtilis.ContactSortModel;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @auathor ${XiaoJianghong}
 * @date 2017/6/26.
 */

public class ProductDetailItemAdapter extends RecyclerView.Adapter<ProductDetailItemAdapter.ItemHolder> {

    private Context context;
    private List<ProductInfoBean.RateBean> beans = new ArrayList<>();
    public ProductDetailItemAdapter(Context context) {
        this.context = context;
    }

    public void addData(List<ProductInfoBean.RateBean> beans) {
        this.beans = beans;
        notifyDataSetChanged();
    }



    @Override
    public ItemHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_base_info, parent, false);
        return new ItemHolder(view);
    }

    @Override
    public void onBindViewHolder(ItemHolder holder, final int position) {
        holder.details_rate_money1_tv.setText(beans.get(position).getMoney());
        holder.details_rate_profit1_tv.setText(beans.get(position).getProfit());
        if(!AppUtil.isExamine(context)){
            holder.details_rate_rebate1_tv.setText("登录可见");
        }else{
            holder.details_rate_rebate1_tv.setText(beans.get(position).getRebate());
        }
    }

    @Override
    public int getItemCount() {
        return beans == null ? 0 : beans.size();
    }

    class ItemHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.details_rate_money1_tv)
        TextView details_rate_money1_tv;
        @BindView(R.id.details_rate_profit1_tv)
        TextView details_rate_profit1_tv;
        @BindView(R.id.details_rate_rebate1_tv)
        TextView details_rate_rebate1_tv;

        public ItemHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }


}